<!DOCTYPE html>
<html lang="en">
<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/css/common.css">
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">所有回收订单</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingOne">
                            <h4 class="panel-title">
                                <a role="button" data-toggle="collapse" data-parent="#accordion"
                                   href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                    搜索栏
                                </a>
                            </h4>
                        </div>
                        <div id="collapseOne" class="panel-collapse collapse " role="tabpanel"
                             aria-labelledby="headingOne">
                            <div class="panel-body">
                                <form action="{:U('Index')}" class="form-horizontal" method="get">
                                    <input type="hidden" name="order_type" value="{$CSDATA.order_type}">
                                    <input type="hidden" name="order_id" value="{$CSDATA.order_id}">

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">订单CODE</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="order_code" value="{$CSDATA.order_code}">
                                        </div>
                                        <label class="col-sm-2 control-label">收货人手机</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="order_phone"
                                                   value="{$CSDATA.order_phone}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">收货人名称</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="order_address_name"
                                                   value="{$CSDATA.order_address_name}">
                                        </div>
                                        <label class="col-sm-2 control-label">物流单号</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="order_express_return"
                                                   value="{$CSDATA.order_express_return}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-10 col-sm-offset-2">
                                            <button type="submit" class="btn  btn-primary">筛选</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->

        <div class="row">
            <div class="col-md-12">
                <div class="btn-group btn-group-justified" role="group" aria-label="">
                    <foreach name="ORDER_STATE_SHOW" item="v" key="k">
                        <a id="state{$k}" href="{:U('GetOrder/index')}?order_type={$k}" type="button"
                           class="btn btn-default">{$v}</a>
                    </foreach>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">

                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="dataTable_wrapper">
                            <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <include file="Extends/searchForUser"/>
                                <thead>
                                <tr>
                                    <th style="text-align:center"><input name="all_checkbox" type='checkbox'
                                                                         id="all_checkbox"></th>
                                    <th class="text-center GridSortTh" width="11%" data-order="ISBN">订单编号</th>
                                    <th style="text-align:center">商品</th>
                                    <th style="text-align:center" width="15%" class="text-center GridSortTh"
                                        data-order="TITLE">收货信息
                                    </th>

                                    <th style="text-align:center" class="text-center GridSortTh" data-order="PRESS">
                                        本数
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh"
                                        data-order="PACKING_SPECIFICATION" width="6%">定价和
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh"
                                        data-order="PACKING_SPECIFICATION" width="6%">书籍收益
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh"
                                        data-order="PACKING_SPECIFICATION" width="6%">组团收益
                                    </th>
                                    <th style="text-align:center" width="10%" class="text-center GridSortTh"
                                        data-order="OPENID" width="6%">卖书总金额
                                    </th>
                                    <th style="text-align:center" width="10%" class="text-center GridSortTh"
                                        data-order="OPENID">订单开始时间
                                    </th>
                                    <th style="text-align:center" width="10%" class="text-center GridSortTh"
                                        data-order="OPENID">物流单号/操作
                                    </th>
                                    <th style="text-align:center" width="20%">备注</th>
                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="data" item="v">
                                    <if condition="$v.order_type == -1 || $v.order_type == 6">
                                        <tr style="color: silver">
                                            <else/>
                                            <if condition="$v.GROUP_ID != NULL">
                                                <!--拼团订单-->
                                                <tr style="color: #0785d1">
                                                    <else/>
                                                <tr>
                                            </if>
                                    </if>


                                    <td><input type='checkbox' name='checkbox'></td>
                                    <td onclick="showBook($(this));">{$v.order_code}<br/><br/>{$v.order_id}</td>
                                    <td>
                                        <table hidden frame="void" width="200" border="1" cellspacing="0"
                                               cellpadding="0">
                                            <foreach name="v.order_books" item="v1">
                                                <if condition="$v1.state == 0">
                                                    <input name="red" type="hidden" value="1">
                                                </if>
                                                <if condition="$v1.hs_type == 1">
                                                    <tr>
                                                        <else/>
                                                    <tr style="color: silver">
                                                </if>
                                                <td>
                                                    <div><a target="_blank"
                                                            href="{:U('Book/index')}?ISBN={$v1.isbn}"><span
                                                            style="color: red">{$v1.isbn}</span></a></div>
                                                    <if condition="$v.order_type == 3">
                                                        <div onclick="changeBook('{$v1.book_id}','{$v1.ob_id}')">
                                                            <img style="height: 120px;width:110px"
                                                                 src="{$v1.ob_book_pic}">
                                                        </div>
                                                        <else/>
                                                        <div>
                                                            <img style="height: 120px;width:110px"
                                                                 src="{$v1.ob_book_pic}">
                                                        </div>
                                                    </if>
                                                    <div><span>{$v1.ob_name}</span></div>
                                                    <div><span class="text-muted">{$v1.ob_book_gg}</span></div>
                                                </td>
                                                <td width="100px">
                                                    <div>定价:<span class="text-muted">{$v1.ob_old_money}</span>
                                                    </div>
                                                    <div>回收价:<span class="text-success"
                                                                   onclick='updateBookMoney("{$v1.ob_id}",$(this))'>{$v1.ob_pay_money}</span>
                                                    </div>
                                                    <p>{$v1.ob_num} 件</p>
                                                    <if condition="$v.order_type gt 2">
                                                        <if condition="$v1.state == 0">
                                                            <p onclick='bookshShow("{$v1.ob_id}",$(this),0)'
                                                               class="btn btn-danger btn-xs">未审核</p>
                                                        </if>
                                                        <if condition="$v1.state == -1">
                                                                    <span onclick='bookshShow("{$v1.ob_id}",$(this),1)'
                                                                          style="color: red;font-size:70%">{$v1.info}</span>
                                                            <else/>
                                                                    <span onclick='bookshShow("{$v1.ob_id}",$(this),1)'
                                                                          style="color: #117700;font-size:70%">{$v1.info}</span>
                                                        </if>
                                                    </if>

                                                    <!--书籍审核是否回收-->
                                                    <if condition="$v.order_type == 1">
                                                        <if condition="$v1.hs_type == 1">
                                                            <p data-align="-1"
                                                               onclick='sfHsBoookTC("{$v1.ob_id}",$(this),"{$v1.order_id}")'
                                                               class="btn btn-warning btn-xs">回收</p>
                                                        </if>
                                                        <if condition="$v1.hs_type == -1">
                                                            <p data-align="1"
                                                               onclick='sfHsBoookTC("{$v1.ob_id}",$(this),"{$v1.order_id}")'
                                                               class="btn btn-warning btn-xs">不回收</p>
                                                        </if>
                                                    </if>
                                                    <if condition="$v.order_type == 5 && $v1.hs_type == 1 && $v1.state == 1 ">
                                                        <if condition="$v1.book_id gt 0">
                                                            <if condition=" $v1.hs_rk_wz == null">
                                                                <br/><span
                                                                    onclick="HsBookRK('{$v1.book_id}','{$v.user_id}','{$v1.ob_id}',$(this))"
                                                                    class="btn btn-warning btn-xs">入库</span>
                                                                <else/>
                                                                <a target="_blank"
                                                                   href="{:U('StoreHouse/Bookindex')}?BHCODE={$v1.hs_rk_wz}"><span
                                                                        class="btn btn-warning btn-xs"
                                                                        style="color: red">已入库，点击查看位置</span></a>
                                                            </if>
                                                            <else/>
                                                            <span style="color: red">平台暂无改书籍信息，无法入库</span>
                                                        </if>
                                                    </if>
                                                </td>
                                                </tr>
                                            </foreach>
                                        </table>
                                    </td>
                                    <td>
                                        <a target="_blank" class="btn btn-warning btn-xs"
                                           href="{:U('User/Index')}?user_id={$v.user_id}">{$v.user_wx_name}</a><br/>
                                        {$v.order_address_name}<br/>
                                        <span style="color: #008a00">{$v.order_phone}</span><br/>
                                        {$v.order_address}<br/>
                                        <span style="color: #1abc9c">{$v.order_get_time}</span>
                                    </td>
                                    <td>{$v.order_num}</td>
                                    <td>{$v.order_old_money}</td>
                                    <td>{$v.order_book_money}</td>
                                    <if condition="$v.GROUP_ID != NULL">
                                        <td>
                                            <if condition="$v.order_type gt 3">
                                                {$v.order_yh_money}<br/>
                                            </if>
                                            <if condition="$v.order_type != -1 && $v.order_type != 6">
                                            <span class="btn btn-warning btn-xs"
                                                  onclick="checkGroupOrder('{$v.GROUP_ID}')">查看团</span>
                                            </if>
                                        </td>
                                        <else/>
                                        <td>非拼团</td>
                                    </if>
                                    <td style="color: red">
                                        <span onclick='updateOrderMoney("{$v.order_id}",$(this))'>{$v.order_money}</span>
                                    </td>
                                    <td>{$v.order_start_time}</td>
                                    <td>
                                        <if condition="$CSDATA.order_type == 1">
                                                <span onclick='HjKd($(this),"{$v.order_id}")'
                                                      class="btn btn-warning btn-xs">呼叫快递</span>
                                            <else/>
                                        </if>
                                        {$v.order_express_return_name}<br/>
                                        {$v.order_express_return}<br/>
                                        <if condition="$CSDATA.order_type == 2">
                                            <if condition="$v.order_express_return == null">
                                                <span onclick='ShowKdModle($(this),"{$v.order_id}")'
                                                      class="btn btn-danger btn-xs">填写订单号</span>
                                            </if>
                                             <span onclick='QRSH("{$v.order_id}")'
                                                   class="btn btn-warning btn-xs">平台确认收货</span>
                                        </if>
                                        <if condition="$CSDATA.order_type == 4">
                                             <span onclick='QRDK("{$v.order_id}")'
                                                   class="btn btn-warning btn-xs">平台确认打款</span>
                                        </if>
                                    </td>
                                    <td>
                                        <if condition="outS('USER_NAME') == 'mao' && $v.order_type != -1">
                                            <a href="{:U('Order/WDelOrder')}?order_id={$v.order_id}"
                                               class="btn btn-danger btn-xs">伪删除</a><br/>
                                        </if>

                                        <if condition="$v.order_type == 1">
                                            <span>《下单成功，等待呼叫快递》</span>
                                        </if>
                                        <if condition="$v.order_type == 2">
                                            <span>《填写订单号，与确认收货》</span>
                                        </if>
                                        <if condition="$v.order_type == 3">
                                            <span>《品相审核》</span>
                                        </if>
                                        <if condition="$v.order_type == 4">
                                            <span>《平台贷款》</span>
                                        </if>
                                        <if condition="$v.order_type ==5">
                                            <span>《已完成》</span>
                                        </if>
                                        <if condition="$v.order_type == 6">
                                            <span>《已关闭》</span>
                                        </if>
                                        <if condition="$v.order_type == -1">
                                            <span>《伪删除》</span>
                                        </if>

                                        <br/><span onclick="AddAdminRemarks('{$v.order_id}','{$v.order_remarks}')"
                                                   class="btn btn-warning btn-xs">管理员修改/添加备注</span> <br/>
                                        {$v.order_remarks}
                                        <if condition="$v.order_type == 5 && $v1.state == 1">
                                            <br/><span onclick="YJRK('{$v.order_id}','{$v.user_id}')"
                                                       class="btn btn-warning btn-xs">一键入库</span>
                                        </if>
                                    </td>

                                    </tr>
                                </foreach>
                                </tbody>
                            </table>
                            <div class="blue">{$show}</div>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
    </div>
    <!-- /#page-wrapper -->
</div>


<!--快递单号-->
<div id="KDDH" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">填写快递信息</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <input id="dk_order_id" type="hidden" name="order_id" value="">

                        <div class="col-xs-12">
                            <label>快递公司</label>
                            <select class="rugby-login form-control" id="KDNAME">
                                <foreach name="KDGS" item="v" key="k">
                                    <option value="{$v['region_name']}">{$v['region_name']}</option>
                                </foreach>
                            </select>
                        </div>
                        <div class="col-xs-12">
                            <label>订单号</label>
                            <input class="rugby-login form-control" id="KDCODE">
                        </div>
                        <div class="col-xs-6 modal-footer">
                            <button onclick="OrderFH()" class="btn btn-block btn-primary">保存</button>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<!--快递单号-->

<!--修改订单金额-->
<div id="allayModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">修改订单金额</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <input id="order_id" type="hidden" name="order_id" value="">

                        <div class="col-xs-12">
                            <label>订单金额</label>
                            <input id="order_money" name="order_money" class="rugby-login form-control" value="">
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button onclick="updatecost()">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!--修改订单金额-->

<!--修改书籍金额-->
<div id="UpdataBookCost" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">修改书籍金额</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <input id="obid" type="hidden" name="obid" value="">

                        <div class="col-xs-12">
                            <label>书籍金额</label>
                            <input id="obpaymoney" name="obpaymoney" class="rugby-login form-control" value="">
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button onclick="updatebookcost()">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!--修改书籍金额-->

<!--书籍审核-->
<div id="BOOKSH" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">书籍品相审核</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <input id="ob_id" type="hidden" name="ob_id" value="">
                        <input id="update" type="hidden" name="update" value="">

                        <div class="col-xs-12">
                            <label>是否通过</label>
                            <select class="rugby-login form-control" id="ob_state">
                                <option value="0">请选择</option>
                                <option value="1">通过</option>
                                <option value="-1">不通过</option>
                            </select>
                        </div>
                        <div class="col-xs-12" id="ob_info_lable">
                            <label>备注</label>
                            <select class="rugby-login form-control" id="ob_info" style="display:none">
                                <option value="通过">请选择</option>
                                <foreach name="PXSH" item="v" key="k">
                                    <option value="{$v.region_name}">{$v.region_name}</option>
                                </foreach>
                            </select>
                            <input id="ob_info_input" class="rugby-login form-control" style="display:none">
                        </div>
                        <div class="col-xs-6 modal-footer">
                            <button onclick="bookshHanld()" class="btn btn-block btn-primary">保存</button>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<!--书籍审核-->


<!--查看拼团信息-->
<div id="CheckGroupOrder" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">查看拼团信息</h4>
            </div>
            <div class="modal-body">
                <table id="my-orders" class="table table-responsive table-bordered" style="margin-top: 10px"
                       border="0">
                    <tr style="color: #008200;color-interpolation: red;align-content: center">

                        <th style="text-align:center">头像</th>
                        <th style="text-align:center">昵称</th>
                        <th style="text-align:center">参团时间</th>
                        <th style="text-align:center">本书</th>
                        <th style="text-align:center">结束时间</th>
                    </tr>
                    <tbody id="context">
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<!--查看拼团信息-->

<!--入库-->
<div id="HSBOOKRK" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <a href="{:U('StoreHouse/Index')}" target="_blank"><h4 class="modal-title text-center">点击到仓库中复制书柜编号</h4>
                </a>
            </div>
            <form action="{:U('HsBookRK')}" method="post">
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <input id="HS_BOOK_ID" type="hidden" name="book_id" value="">
                            <input id="USER_ID" type="hidden" name="USER_ID" value="">
                            <input id="HS_OB_ID" type="hidden" name="HS_OB_ID" value="">

                            <input id="YJ_order_id" type="hidden" name="YJ_order_id" value="">
                            <input id="YJ_user_id" type="hidden" name="YJ_user_id" value="">

                            <div class="col-xs-12">
                                <label>输入书柜编号</label>
                                <input id="SG_CODE" name="SG_CODE" class="rugby-login form-control" value="">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit">
                        确认
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--入库-->


<!--书籍列表-->
<div id="BOOKLIST" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">书籍列表</h4>
            </div>
            <div class="modal-body">
                <table class="table table-responsive table-bordered" style="margin-top: 10px"
                       border="0">
                    <tr style="color: #008200;color-interpolation: red;align-content: center">
                        <th style="text-align:center">图片</th>
                        <th style="text-align:center" width="200px">书名</th>
                        <th style="text-align:center">作者</th>
                        <th style="text-align:center">出版社</th>
                        <th style="text-align:center">包装</th>
                        <th style="text-align:center">定价</th>
                        <th style="text-align:center">操作</th>
                    </tr>
                    <tbody id="context1">
                    </tbody>
                </table>
                <a target="_blank" href="{:U('Book/EditBookIndex')}"> <span class="btn  btn-primary">去添加书籍</span></a>
            </div>
        </div>
    </div>
</div>
<!--书籍列表-->

<!--修改订单备注-->
<div id="AddAdminRemarks" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">管理员修改/添加备注</h4>
            </div>
            <form action="{:U('AddOrderRemarks')}" method="post">
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <input id="o_id" type="hidden" name="order_id" value="">

                        <div class="col-xs-12">
                            <label>备注信息</label>
                            <textarea rows="5" id="order_remarks" name="order_remarks" class="rugby-login form-control" value=""></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit">
                    确认
                </button>
            </div>
            </form>
        </div>
    </div>
</div>
<!--修改订单备注-->


<include file="CommonSidebar:common-script"/>
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>

<script>
    //添加管理员备注弹窗
    function AddAdminRemarks(o_id,order_remarks){
        $('#o_id').val(o_id);
        $('#order_remarks').val(order_remarks);
        $('#AddAdminRemarks').modal('show');
    }

    //回收书籍入库弹窗
    function HsBookRK(book_id, user_id, ob_id, elem) {
        $('#HS_BOOK_ID').val(book_id);
        $('#USER_ID').val(user_id);
        $('#HS_OB_ID').val(ob_id);
        $('#HSBOOKRK').modal('show');
    }
    //回收书籍入库弹窗
    function YJRK(order_id, user_id) {
        $('#YJ_order_id').val(order_id);
        $('#YJ_user_id').val(user_id);
        $('#HSBOOKRK').modal('show');
    }

    //修改回收订单书籍
    function changeBook(book_id, ob_id) {
        $.post("{:U('Book/GetBookListToIDInISBN')}", {ID: book_id}, function (data) {
            console.log(data);
            if (data) {
                $("#context1").html("");
                for (var i in data) {
                    var html = '';
                    html += '<tr>';
                    html += '<td ><img width="50px" src="' + data[i]['PIC_URL'] + '"></td>';
                    html += '<td >' + data[i]['TITLE'] + '</td>';
                    html += '<td >' + data[i]['AUTHOR'] + '</td>';
                    html += '<td >' + data[i]['PRESS'] + '</td>';
                    html += '<td >' + data[i]['PACKING_SPECIFICATION'] + '</td>';
                    html += '<td >' + data[i]['Y_PRICE'] + '</td>';
                    html += "<td ><form action=\"{:U('GetOrder/updateOrderBook')}\" method='post'>" +
                            '<input type="hidden" name="old_ob_id" value="' + ob_id + '">' +
                            '<input type="hidden" name="book_id" value="' + data[i]['ID'] + '">';
                    if (data[i]['ID'] != book_id) {
                        html += '<button type="submit" class="btn btn-warning btn-xs">确认修改</button>';
                    }
                    html += '</form>' +
                            '</td>';
                    html += '</tr>';
                    $("#context1").append(html);
                }
                $('#BOOKLIST').modal('show');
            }
        });
    }

    //是否回收书籍弹窗
    function sfHsBoookTC(ob_id, elem, order_id) {
        var hs_type = elem.attr("data-align");
        $.post("{:U('GetOrder/IFHSBOOK')}", {
            ob_id: ob_id, hs_type: hs_type, order_id: order_id
        }, function (data) {
            console.log(data);
            if (data != -1) {
                if (hs_type == 1) {
                    elem.html('回收');
                    elem.attr("data-align", -1);
                    elem.parent().parent().css("color", "");
                } else {
                    elem.html('不回收');
                    elem.attr("data-align", 1);
                    elem.parent().parent().css("color", "silver");
                }
                if (data == -2) {
                    if (confirm("订单回收价已经低于20，是否取消订单？")) {
                        $.post("{:U('GetOrder/DelOrderInHSBook')}", {
                            order_id: order_id
                        }, function (OK) {
                            if (OK) {
                                alert('订单取消成功');
                            } else {
                                alert('订单取消失败，请核对');
                            }
                            window.location.reload();
                        });
                    } else {
                        alert('不取消订单，请修改回收书籍');
                    }
                }
            } else {

            }
        });
    }


    //查看拼团
    function checkGroupOrder(group_id) {
        console.log(group_id);
        $.post("{:U('GetOrder/checkGroupOrder')}", {
            GROUP_ID: group_id
        }, function (data) {
            console.log(data);
            if (data) {
                $("#context").html("");
                for (var i in data) {
                    var html = '';
                    html += '<tr>';
                    html += '<td ><img width="50px" src="' + data[i]['user_image'] + '"></td>';
                    html += '<td >' + data[i]['user_wx_name'] + '</td>';
                    html += '<td >' + data[i]['join_time'] + '</td>';
                    html += '<td >' + data[i]['order_num'] + '</td>';
                    html += '<td >' + data[i]['group_end_time'] + '</td>';
                    html += '</tr>';
                    $("#context").append(html);
                }

                $('#CheckGroupOrder').modal('show');
            } else {
                alert('查询失败');
            }
        });

    }


    //显示选中订单颜色
    $('#state' + ({$CSDATA['order_type']})).css('background-color', '#0000cc');
    //显示商品
    function showBook(elem) {
        var top = elem.next().find('table');
        if (top.is(":hidden")) {
            top.show();
        } else {
            top.hide();
        }
    }

    //呼叫快递
    function HjKd(elem, order_id) {
        if (confirm("请确认书籍是否需要，再确认呼叫快递！继续点击确定")) {
            $.post("{:U('GetOrder/HjKd')}", {
                order_id: order_id
            }, function (OK) {
                if (OK) {
                    alert('添加快递信息成功');
                    window.location.reload();
                } else {
                    alert('添加快递信息失败');
                }
            });
        }
    }

    //书籍审核弹窗
    var shebutton = '';
    //update 1修改
    function bookshShow(ob_id, elem, update) {
        if ('{$CSDATA.order_type}' == 3) {
            $('#BOOKSH').modal("show");
            $('#ob_id').val(ob_id);
            $('#update').val(update);
            shebutton = elem;
        }

    }
    //书籍审核选择通过，无理由
    $("select#ob_state").change(function () {
        var sh_state = $(this).val();
        if (sh_state == 1) {
            $("#ob_info").hide();
            $("#ob_info_input").show();
        } else {
            $("#ob_info_input").hide();
            $("#ob_info").show();

        }

    });
    //审核书籍操作
    function bookshHanld() {
        var ob_id = $('#ob_id').val();
        var state = $('#ob_state').val();
        if (state == 1) {
            var info = $('#ob_info_input').val();
        } else {
            var info = $('#ob_info').val();
        }
        var update = $('#update').val();
        $.post("{:U('HSOrderBookSH')}",
                {ob_id: ob_id, info: info, state: state, update: update},
                function (data) {
                    if (data > 0) {
                        shebutton.hide();
                        $('#BOOKSH').modal("hide");
                        alert('审核成功');
                        if (data != 1) {
                            alert('改订单所有书籍已审核完毕，共' + data + '元');
                            window.location.href = "{:U('GetOrder/index')}?order_type=4";
                        }
                    } else {
                        alert('审核失败');
                    }
                });
    }

    //确认收货
    function QRSH(id) {
        if (confirm("是否确认收货？")) {
            $.post("{:U('HSOrderChange')}",
                    {order_id: id, TYPE: 3},
                    function (data) {
                        if (parseInt(data) == 1) {
                            alert('确认成功');
                            window.location.reload();
                        } else {
                            alert('确认失败');
                        }
                    });
        }
    }

    //填写快递信息
    function ShowKdModle(elem, order_id) {
        $('#KDDH').modal("show");
        $('#dk_order_id').val(order_id);
    }
    //订单发货 kd_type =1 是回收订单
    function OrderFH() {
        var KDNAME = $('#KDNAME').val();
        var KDCODE = $('#KDCODE').val();
        var id = $('#dk_order_id').val();
        $.post("{:U('GetOrder/FHhanld')}", {
            order_id: id,
            KDNAME: KDNAME,
            KDCODE: KDCODE,
        }, function (OK) {
            if (OK) {
                alert('添加快递信息成功');
                window.location.reload();
            } else {
                alert('添加快递信息失败');
            }
        });

    }
</script>

<script>
    var elem_all = '';
    //修改订单价格弹窗
    function updateOrderMoney(ID, elem) {
        if ('{$CSDATA.order_type}' == 4) {
            elem_all = elem;
            $("#order_id").val(ID);
            $("#order_money").val(elem.html());
            $("#allayModal").modal("show");
        }
    }
    //修改书籍金额
    function updateBookMoney(ID, elem) {
        if ('{$CSDATA.order_type}' == 4 || '{$CSDATA.order_type}' == 1 || '{$CSDATA.order_type}' == 3) {
            elem_all = elem;
            $("#obid").val(ID);
            $("#obpaymoney").val(jQuery.trim(elem.html()));
            $("#UpdataBookCost").modal("show");
        }
    }
    //修改订单价格处理
    function updatecost() {
        var ID = $("#order_id").val();
        var money = jQuery.trim($("#order_money").val());

        if (confirm("确认修改？")) {
            $.post("{:U('updatecost')}",
                    {ID: ID, money: money},
                    function (data) {
                        console.log(data);
                        if (parseInt(data) == 1) {
                            alert('修改成功');
                            elem_all.html(money);
                        } else {
                            alert('修改失败');
                        }
                    });
            $("#allayModal").modal("hide");
        }
    }

    //修改书籍价格处理
    function updatebookcost() {
        var ID = $("#obid").val();
        var money = $("#obpaymoney").val();

        if (confirm("确认修改？")) {
            $.post("{:U('updatebookcost')}",
                    {ID: ID, money: money},
                    function (data) {
                        console.log(data);
                        if (parseInt(data) == 1) {
                            alert('修改成功');
                            elem_all.html(money);
                        } else {
                            alert('修改失败');
                        }
                    });
            $("#UpdataBookCost").modal("hide");
        }
    }
    //平台确认打款
    function QRDK(order_id) {
        if (confirm("是否确认打款？请核对金额")) {
            $.post("{:U('HSOrderChange')}",
                    {order_id: order_id, TYPE: 5},
                    function (data) {
                        if (parseInt(data) == 1) {
                            alert('确认成功');
                            window.location.reload();
                        } else {
                            alert('确认失败');
                        }
                    });
        }
    }
</script>
</body>
</html>
